GDK W32: Plug a resource leak
authorРуслан Ижбулатов <lrn1986@gmail.com>
Mon, 4 Sep 2017 14:42:11 +0000 (14:42 +0000)
committerРуслан Ижбулатов <lrn1986@gmail.com>
Sun, 3 Dec 2017 03:19:02 +0000 (03:19 +0000)
Ensure that surfaces allocated in the impl are destroyed in finalize()

https://bugzilla.gnome.org/show_bug.cgi?id=787089

gdk/win32/gdkwindow-win32.c

index 88c18cc71cd8f7dba9fa1cc62db357de07ef75cb..24db897265474a20c0f0d456bdcf9e186719c182 100644 (file)
@@ -236,6 +236,23 @@ gdk_window_impl_win32_finalize (GObject *object)
 
   g_free (window_impl->decorations);
 
+  if (window_impl->cache_surface)
+    {
+      cairo_surface_t_note_about_to_dereference (window_impl->cache_surface);
+      cairo_surface_destroy (window_impl->cache_surface);
+      window_impl->cache_surface = NULL;
+    }
+
+  if (window_impl->cairo_surface)
+    {
+      cairo_surface_t_note_about_to_dereference (window_impl->cairo_surface);
+      cairo_surface_destroy (window_impl->cairo_surface);
+      window_impl->cairo_surface = NULL;
+    }
+
+  g_assert (window_impl->transient_owner == NULL);
+  g_assert (window_impl->transient_children == NULL);
+
   G_OBJECT_CLASS (parent_class)->finalize (object);
 }